Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primes #7

Closed
wants to merge 5 commits into from
Closed

Primes #7

wants to merge 5 commits into from

Conversation

AngelEzquerra
Copy link
Contributor

@AngelEzquerra AngelEzquerra commented May 31, 2024

This PR adds a few prime related functions:

  • primes: Generate prime values up to a number
  • factor: Factorize a number
  • isprime: Check if a number (or a tensor element-wise) is prime

These can be used in a number of digital communications and cryptography related algorithms.

Prime numbers are an essential building block of many algorithms in diverse areas such as cryptography, digital communications and many others.

This module adds a function to generate lists of primes upto a certain value.

For now it just adds
This is faster than first calculating the primes of an integer number and then converting the result to a tensor of floats. For large `upto` numbers the difference is substantial.
This new function returns a Tensor containing the prime factors of the input.
Single element and element-wise functions that return true when their inputs are prime numbers.
@mratsim
Copy link
Collaborator

mratsim commented Jun 4, 2024

This should be in a number-theory repo I think?

@AngelEzquerra
Copy link
Contributor Author

This should be in a number-theory repo I think?

Prime number generation and checking are quite common in signal processing and digital communications. For example, primes are used to generate sequences such as Zadoff-Chu which are used in all sorts of context in 5G cellular systems (e.g. to generate sync and reference signals, random access and to transmit control information).

I agree that these could perhaps be put in a separate repo, along with procedures to generate bessel functions, etc., but then impulse would end up having to reference that separate repo (e.g. bessel functions are required to the Kaiser filter windows that I added in the other PR I recently sent: #6). So, for now, I would just keep them all in impulse (which is still kind of empty anyway) as I don't intend to add many more of these beyond what's strictly needed to add more signal processing capabilities to impulse. If these grow much beyond that scope, we could split them up into their own repo later.

What do you think?

@Vindaar
Copy link
Member

Vindaar commented Jun 7, 2024

We have the https://github.com/SciNim/scinim repo, which could be another alternative. In general though in the current Nim landscape I think fewer, but larger repos are better than many tiny ones for discoverability.

@AngelEzquerra AngelEzquerra mentioned this pull request Jun 15, 2024
@AngelEzquerra
Copy link
Contributor Author

I just made SciNim/scinim#16 to add this code to the scinim repo rather than to impulse.

@Vindaar
Copy link
Member

Vindaar commented Jun 17, 2024

As it's part of scinim now, closing this.

@Vindaar Vindaar closed this Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants